#include<bits/stdc++.h>
using namespace std;
const int N=100005;
int t;
int n,m,len,mv,sum,sum1;
int p[N];
int num[N];
struct car{
int d,v,a;
}c[N];
int x;
double x1;
int ef(int d){
int l=1,r=m,mid;
while(l<=r){
    mid=l+(r-l)/2;
    if(p[mid]>d)r=mid-1;
    else l=mid+1;
}
if(l==m+1)return -1;
else return l;
}
int main(){
freopen("detect.in","r",stdin);
freopen("detect.out","w",stdout);
cin>>t;
for(int z=1;z<=t;z++){
        cin>>n>>m>>len>>mv;
        for(int i=1;i<=n;i++){
            cin>>c[i].d>>c[i].v>>c[i].a;
        }
        for(int i=1;i<=m;i++)cin>>p[i];
        sort(p+1,p+1+m);
        for(int i=1;i<=n;i++){//cout<<i<<":";
            /*if(c[i].a<=0){
                if(c[i].v>mv){
                        sum++;
                    x=ef(c[i].d);
                    for(int j=x;j<=m;j++){
                        if(sqrt(c[i].v*c[i].v-2*c[i].a*(p[j]-c[i].d))<=1.0*mv)continue;
                        num[j]++;
                        cout<<j<<" ";
                    }
                }
            }else{*/
            if(c[i].a==0){
                if(c[i].v>mv){
                    for(int j=1;j<=m;j++){
                        num[j]++;
                    }sum++;
                }

            }else{
            double x1=1.0*(mv*mv-c[i].v*c[i].v)/c[i].a/2;
                if(double(len-c[i].d)>=x1){
                        sum++;
                    x=ef(int(c[i].d+x1));
                    for(int j=x;j<=m;j++){
                            //cout<<j<<" ";
                        num[j]++;
                    }
                }
            }//cout<<endl;
            }

        //}
        cout<<sum<<" ";
        if(sum)cout<<m-1<<endl;
        else cout<<m<<endl;

}
return 0;
}
